from django.utils.deprecation import MiddlewareMixin

class TestMiddleare(MiddlewareMixin):
    # 每次请求前 都会调用执行
    def process_request(self,request):
        print('1111process_request')

        # user=request.COOKIES.get('user')
        # if user is not None:
        #     print('登录用户')
        # else:
        #     print('非登录用户')


    def process_response(self,request, response):
        print('1111111process_response')

        response['server']='xxxxx'
        return response

class TestMiddleare2(MiddlewareMixin):

    def process_request(self,request):
        print('222222process_request')

        # user=request.COOKIES.get('user')
        # if user is not None:
        #     print('登录用户')
        # else:
        #     print('非登录用户')


    def process_response(self,request, response):
        print('22222process_response')

        response['server']='xxxxx'
        return response


###执行顺序###
'''
请求由上往下
响应由下往上
'''